import request from '../../utils/request';
import config from '../../utils/config';

const { api } = config;
const { common: {
  findDictionarys,
  findSystemExplains,
} } = api;

type FindDictionarysInput = {
	dictCode?: string, // 字典代码
}
type FindDictionarysOutput = {
  code: number,
  note: string,
  records: {
		dictCode: string,
		dictName: string,
		ibm: string,
		cbm: string,
		note: string,
		flag: string,
		type: string,
		categ: string,
	}[]
};
// 获取数据字典
export async function FindDictionarys(payload: FindDictionarysInput): Promise<FindDictionarysOutput> {
  const option = {
    url: findDictionarys, // crm/v1/common/dic/list
    method: 'GET',
    data: payload,
  };
  return request(option);
}

type FindSystemExplainsInput = {
	propCode?: string, // 方案代码
	sysType?: string, // 系统类别字典:SYS_TYPE(1|PC;2|APP;3| )，这里固定传1 
	ibm?: string, // 标识码
	clas?: string, // 分类字典:SYS_EXPL_CLAS
}
type FindSystemExplainsOutput = {
  code: number,
  note: string,
  records: {
		id: string,	//ID
		sysType: string,	//系统类型
		ibm: string,	//编码
		title: string,	//标题
		expl: string,	//内容
		order: string,	//顺序
		memo: string,	//备注
		propCode: string,	//方案代码
		clasId: string,	//分类ID
		clasName: string,	//分类名称
	}[]
};
// 获取系统说明
export async function FindSystemExplains(payload: FindSystemExplainsInput): Promise<FindSystemExplainsOutput> {
  const option = {
    url: findSystemExplains, // crm/v1/common/sysexp/list
    method: 'GET',
    data: payload,
  };
  return request(option);
}
